﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Activity.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The activity.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Models.Domain
{
    using System;
    using System.Collections.Generic;

    using NHibernate.Mapping.ByCode.Conformist;

    using ServiceLibrary.Models.Base;

    /// <summary>
    /// The activity.
    /// </summary>
    public class Activity : Entity
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Activity"/> class.
        /// </summary>
        public Activity()
        {
            this.Attendees = new HashSet<Profile>();
            this.OwnerProjects = new HashSet<Project>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the attendees.
        /// </summary>
        public virtual ICollection<Profile> Attendees { get; set; }

        /// <summary>
        /// Gets or sets the bda.
        /// </summary>
        public virtual BusinessDevelopmentActivity BDA { get; set; }

        /// <summary>
        /// Gets or sets the commentary.
        /// </summary>
        public virtual string Commentary { get; set; }

        /// <summary>
        /// Gets or sets the creator.
        /// </summary>
        public virtual User Creator { get; set; }

        /// <summary>
        /// Gets or sets the location.
        /// </summary>
        public virtual Location Location { get; set; }

        /// <summary>
        /// Gets or sets the na.
        /// </summary>
        public virtual NetworkingActivity NA { get; set; }

        /// <summary>
        /// Gets or sets the owner projects.
        /// </summary>
        public virtual ICollection<Project> OwnerProjects { get; set; }

        /// <summary>
        /// Gets or sets the time of activity.
        /// </summary>
        public virtual DateTime? TimeOfActivity { get; set; }

        #endregion
    }

    /// <summary>
    /// The activity mapping.
    /// </summary>
    public class ActivityMapping : ClassMapping<Activity>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ActivityMapping"/> class.
        /// </summary>
        public ActivityMapping()
        {
            this.Set(x => x.OwnerProjects, c => { }, m => m.ManyToMany());

            this.Property(x => x.TimeOfActivity);
            this.Property(x => x.Commentary, m => m.Length(int.MaxValue / 2));

            this.ManyToOne(x => x.Creator);
            this.ManyToOne(x => x.Location);

            this.Set(x => x.Attendees, c => { }, m => m.ManyToMany());
            this.ManyToOne(x => x.BDA);
            this.ManyToOne(x => x.NA);
        }

        #endregion
    }
}